package com.bookmanger.server.controller;

import com.bookmanger.common.result.Result;
import com.bookmanger.server.service.ISBNService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/isbn")
@Slf4j
public class ISBNController {
    
    @Autowired
    private ISBNService isbnService;
    
    /**
     * 通过ISBN获取图书信息
     */
    @GetMapping("/info/{isbn}")
    public Result getBookInfoByISBN(@PathVariable String isbn) {
        return isbnService.getBookInfoByISBN(isbn);
    }
    
    /**
     * 批量通过ISBN获取图书信息
     */
    @PostMapping("/batch-info")
    public Result getBookInfoByISBNs(@RequestBody Map<String, Object> request) {
        @SuppressWarnings("unchecked")
        java.util.List<String> isbns = (java.util.List<String>) request.get("isbns");
        return isbnService.getBookInfoByISBNs(isbns);
    }
}